package client;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;

public class Screen_Deposit extends JPanel {
	private JLabel lbldepositMenu;
	private JLabel lbldepositText;
	private JTextField tfdeposit;
	private JButton btnDeposit;
	private JButton btnReturn;

	/**
	 * Create the panel.
	 */

	public Screen_Deposit() {
		setBackground(UIManager.getColor("Label.background"));
		setLayout(null);
		setSize(320, 480);

		lbldepositMenu = new JLabel("Deposit funds");
		lbldepositMenu.setOpaque(true);
		lbldepositMenu.setBackground(UIManager.getColor("Label.background"));
		lbldepositMenu.setHorizontalAlignment(SwingConstants.CENTER);
		lbldepositMenu.setForeground(Color.BLACK);
		lbldepositMenu.setFont(new Font("Eurostile", Font.BOLD, 16));
		lbldepositMenu.setBounds(0, 35, 320, 50);
		add(lbldepositMenu);

		lbldepositText = new JLabel("Enter amount in DKK to deposit");
		lbldepositText.setOpaque(true);
		lbldepositText.setBackground(UIManager.getColor("Label.background"));
		lbldepositText.setHorizontalAlignment(SwingConstants.LEFT);
		lbldepositText.setForeground(Color.BLACK);
		lbldepositText.setFont(new Font("Eurostile", Font.PLAIN, 13));
		lbldepositText.setBounds(64, 120, 320, 16);
		add(lbldepositText);

		tfdeposit = new JTextField();
		tfdeposit.setHorizontalAlignment(SwingConstants.LEFT);
		tfdeposit.setBounds(60, 140, 200, 35);
		tfdeposit.setColumns(10);
		tfdeposit.setFont(new Font("Eurostile", Font.PLAIN, 12));
		add(tfdeposit);
		tfdeposit.setColumns(10);

		btnDeposit = new JButton("Insert amount");
		btnDeposit.setHorizontalAlignment(SwingConstants.CENTER);
		btnDeposit.setFont(new Font("Eurostile", Font.PLAIN, 13));
		btnDeposit.setBounds(60, 185, 200, 35);
		add(btnDeposit);

		btnReturn = new JButton("Return to main menu");
		btnReturn.setFont(new Font("Eurostile", Font.BOLD, 14));
		btnReturn.setHorizontalAlignment(SwingConstants.CENTER);
		btnReturn.setBounds(60, 300, 200, 45);
		add(btnReturn);

	}

	/**
	 * Returns JButton
	 * 
	 * @return btnDeposit
	 */
	public JButton getBtnDeposit() {
		return btnDeposit;
	}

	public JButton getBtnReturn() {
		return btnReturn;
	}

	public double getDepositAmount() {
		try {
			return Double.parseDouble(tfdeposit.getText().trim());
		} catch (NumberFormatException e) {
			return -1;
		}

	}

	/**
	 * Clear the fields
	 */
	public void clearFields() {
		tfdeposit.setText("");
	}

	/**
	 * Add ActionListener to JButtons and JTextField
	 * 
	 * @param ActionListener
	 *            l
	 */
	public void addActionListener(ActionListener l) {
		btnDeposit.addActionListener(l);
		btnReturn.addActionListener(l);
		tfdeposit.addActionListener(l);
	}
}